package com.tongji.housediy.model
{
	import com.tongji.housediy.events.commonEvent.RotationRelatedEvent;
	import com.tongji.housediy.events.commonEvent.ShowHideTitleWindowEvent;
	import com.tongji.housediy.view.components.AbstractDrawingRoom;
	import com.tongji.housediy.view.components.InteriorWall;
	import com.tongji.housediy.view.components.RoomBorder;
	import com.tongji.housediy.view.components.RoomFloor;
	
	import mx.core.UIComponent;
	
	import org.robotlegs.mvcs.Actor;
	
	/**
	 * 
	 * @author chenchao
	 * 
	 */
	public class SelectedObjectModel extends Actor
	{
		public var selectedObj:UIComponent;
		
		public function SelectedObjectModel()
		{
		}
		
		public function deleteSelectedObj():void
		{
			if (selectedObj is RoomFloor || (selectedObj is RoomBorder && selectedObj.parent is InteriorWall))
			{
				selectedObj.parent.parent.removeChild(selectedObj.parent);
			}
			else if (selectedObj is RoomBorder && selectedObj.parent is AbstractDrawingRoom)
			{
				(selectedObj as RoomBorder).deleteBorder();
			}
			else
			{
				selectedObj.parent.removeChild(selectedObj);
				this.dispatch(new RotationRelatedEvent(RotationRelatedEvent.HIDE_ROTATION_BTN));
			}
			
			dispatch(new ShowHideTitleWindowEvent(ShowHideTitleWindowEvent.HIDE_TITLE_WINDOW));
		}
	}
}